package au.com.handsunited.web.controller.entity;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.servlet.mvc.SimpleFormController;

import au.com.handsunited.model.invitations.Invitation;

/**
 * @author Object
 *
 */
public abstract class AbstractInviteController extends SimpleFormController {



	protected List<String> getEmailAddressesFromInvitations(List<Invitation> invitations) {

		List<String> emailAddresses = new ArrayList<String>();

		for (Invitation invitation : invitations) {

			if (invitation.getInvitee() == null) {
				emailAddresses.add(invitation.getNonMemberInviteeEmailAddress());
			} else {
				emailAddresses.add(invitation.getInvitee().getContactInfo().getEmailAddress());
			}
		}


		return emailAddresses;
	}


	protected List<String> getInviteeNamesFromInvitations(List<Invitation> invitations) {

		List<String> inviteeNames = new ArrayList<String>();

		for (Invitation invitation : invitations) {

			if (invitation.getInvitee() != null) {
				inviteeNames.add(invitation.getInvitee().getName());
			}
		}


		return inviteeNames;
	}
}
